#表单
import wtforms
from wtforms.validators import Length, EqualTo
from models import User

# class RegisterForm(wtforms.Form):
#     uid= wtforms.StringFiled(validators=[Length(11, message="手机格式错误!")])#即用户id号,唯一确定,可以是pthone
#     username=wtforms.StringFiled(validators=[Length(min=3,max=20,message="用户名格式错误!")])
#     password=wtforms.StringFiled(validators=[Length(min=8,max=20,message="密码格式错误")])
#     password_confirm=wtforms.StringFiled(validators=[EqualTo("password")])#再次确认密码
#
#     #验证手机号也就是用户名id是否已被注册
#     def validate_phone(self,field):
#         uid=field.data
#         user=User.query.fileter_by(uid=uid).first()
#         if user:
#             raise wtforms.ValidationError(message="该账号已被注册!")

class LoginForm(wtforms.Form):
    username = wtforms.StringField(validators=[Length(min=2, max=100, message="用户名格式错误")])
    password = wtforms.StringField(validators=[Length(min=2, max=100, message="密码格式错误")])


